package com.waves.task.strategy.task;

import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.waves.task.domain.dto.TaskPageDTO;
import com.waves.task.domain.enums.TaskTypeEnum;
import com.waves.task.domain.vo.TaskVO;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * 评论贴策略类
 */
@Component
public class TaskCommentStrategy extends AbstractTaskStrategy{

    @Override
    TaskTypeEnum getTaskTypeEnum() {
        return TaskTypeEnum.TASK_TYPE_COMMENT;
    }
    @Override
    public TaskPageDTO dealTaskPageDTO(TaskPageDTO dto) {
        // 个人主页评论
        List<Long> taskIds = taskCommentDao.getCommentTaskIds(dto.getUserId());
        if (CollUtil.isNotEmpty(taskIds)) {
            dto.setTaskIds(taskIds);
        }
        return dto;
    }

    @Override
    public IPage<TaskVO> getTaskVOPage(TaskPageDTO dto) {
        return super.searchAndDealPage(dealTaskPageDTO(dto));
    }


}
